//
//  BHCircleChoseImageOrVideoNavView.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/7/6.
//

import UIKit
protocol BHCircleChoseImageOrVideoNavViewDelegate {
    func didNavigationBarSelectIndex(index: Int)
}

class BHCircleChoseImageOrVideoNavView: UIView {

    var delegate: BHCircleChoseImageOrVideoNavViewDelegate?
    
    @IBOutlet weak var imageBtn: UIButton!
    
    @IBOutlet weak var videoBtn: UIButton!
    
    @IBOutlet weak var lineCenterX: NSLayoutConstraint!
    @IBOutlet weak var moveline: UILabel!
    
    var onlyImage: Bool = false {
        didSet {
            
        }
    }
    
    
    static func loadFromXib() -> BHCircleChoseImageOrVideoNavView {
        let viewArray = Bundle.main.loadNibNamed("BHCircleChoseImageOrVideoNavView", owner: nil, options: nil)
        let view: BHCircleChoseImageOrVideoNavView = viewArray![0] as! BHCircleChoseImageOrVideoNavView
        return view
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        self.moveline.addLayerCorner(2, 0, .white)
    }
    
    @IBAction func back_act(_ sender: UIButton) {
        self.delegate?.didNavigationBarSelectIndex(index: 0)
    }
    
    @IBAction func changeAct(_ sender: UIButton) {
        if sender.isSelected == true {
            return
        }
        
        sender.isSelected = true
        if sender == self.imageBtn {
            self.videoBtn.isSelected = false
            self.delegate?.didNavigationBarSelectIndex(index: 1)
            self.lineCenterX.constant = -28

        }else {
            self.imageBtn.isSelected = false
            self.delegate?.didNavigationBarSelectIndex(index: 2)
            self.lineCenterX.constant = 26
        }
    }
    
}
